package com.suda.catalina.myapplication;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;

/**
 * Created by gzy on 2016/3/15.
 */
public class EditShiredPreferences {

    public static void saveSharedPreferences (Context context, Bundle bundle) {

        //Context类中的getSharedPreferences("data", Context.MODE_PRIVATE)方法
        SharedPreferences.Editor editor = context.getSharedPreferences("data", Context.MODE_PRIVATE).edit();
        editor.putString("name", bundle.getString("name"));
        editor.putString("password", bundle.getString("password"));
        editor.commit();
    }

    public static Bundle loadSharedPreferences (Context context) {

        SharedPreferences sharedPreferences = context.getSharedPreferences("data", Context.MODE_PRIVATE);
        Bundle bundle = new Bundle();
        bundle.putString("name", sharedPreferences.getString("name", ""));
        bundle.putString("password", sharedPreferences.getString("password", ""));
        return bundle;
    }


}
